<html>
<body>
    <input id='text' type='text'></input>

    <script src="../../resources/gc.js"></script>
    <script src="../../resources/js-test.js"></script>
    <script>
        window.jsTestIsAsync = true;

        // Do initialization work in an inner function to avoid references to
        // objects remaining live on this function's stack frame.
        // (http://crbug.com/595672/).
        var markedRangeResultGC, selectedRangeResultGC,
            firstRectForCharacterRangeGC;

        (async () => {
            (function() {
                var input = document.getElementById('text');
                input.focus();
                textInputController.setMarkedText("hello", 0, 5);
                markedRangeResultGC = internals.observeGC(
                    textInputController.markedRange());
                selectedRangeResultGC = internals.observeGC(
                    textInputController.selectedRange());
                firstRectForCharacterRangeGC = internals.observeGC(
                    textInputController.firstRectForCharacterRange(0, 0));
            })();

            await asyncGC();
            shouldBeTrue('markedRangeResultGC.wasCollected');
            shouldBeTrue('selectedRangeResultGC.wasCollected');
            shouldBeTrue('firstRectForCharacterRangeGC.wasCollected');

            finishJSTest();
        })();
    </script>
</body>
</html>
